package com.sqin.taskflow.task;

import com.sqin.taskflow.config.TaskFlowConfig;
import com.sqin.taskflow.exception.WorkflowException;

public class SingleTask extends AbsTask {

    public SingleTask(String name){
        this.name = name;
    }

    @Override
    public Object execute() {

        return null;
    }

    @Override
    public void run() {
        TaskFlowConfig.listen.beforeExecute(this);

        try{
            this.result = this.execute();
            TaskFlowConfig.listen.executeResult(this);
        }catch (Exception e){
            this.result = e;
            TaskFlowConfig.listen.exception(this,e);
            throw new WorkflowException(e.getMessage());
        }
        TaskFlowConfig.listen.afterExecute(this);
    }
}
